package com.yswy.domain.vo.dto;

import com.baomidou.mybatisplus.annotation.TableName;
import com.yswy.domain.common.BasePojo;
import com.yswy.domain.common.util.MoneyUtils;
import com.yswy.domain.entity.TransferOrder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
public class TransferOrderVo{

    @ApiModelProperty("订单Id")
    private String orderId;
    @ApiModelProperty("转账金额")
    private String refundAmount;
    @ApiModelProperty("转账原因")
    private String refundDesc;
    @ApiModelProperty("三方Body")
    private String prompt;
    @ApiModelProperty("三方Body")
    private String errorMsg;
    @ApiModelProperty("转账状态  0:失败 1:成功 2:转账中  ")
    private Integer refundStatus;

    @ApiModelProperty("转账时间")
    private Date refundTime;
    @ApiModelProperty("转账方式  0 支付宝   1 微信")
    private Integer paymentType;
    @ApiModelProperty("创建时间")
    private Date createTime ;

    public TransferOrderVo(TransferOrder transferOrder) {

        this.orderId = transferOrder.getOrderId();
        String refundAmount = MoneyUtils.getPriceString(transferOrder.getRefundAmount().doubleValue()/100);
        this.refundAmount = refundAmount;

//        @ApiModelProperty("提现位置  0 首页小额提现  1 金币提现   2 红包提现")
//        private Integer transferPosition;
//
        if (transferOrder.getTransferPosition() == 0){
            this.refundDesc="任务提现至"+ (transferOrder.getPaymentType()==0?"支付宝":"微信");
        }else if (transferOrder.getTransferPosition() == 1){
            this.refundDesc="金币提现至"+ (transferOrder.getPaymentType()==0?"支付宝":"微信");
        }else if (transferOrder.getTransferPosition() == 2){
            this.refundDesc="红包提现至"+ (transferOrder.getPaymentType()==0?"支付宝":"微信");
        }
        if (transferOrder.getRefundStatus() == 0 ){
            this.prompt = "提现失败，退回金额"+refundAmount+"元";
            if (transferOrder.getIsProcess() == 1){
                this.errorMsg = transferOrder.getRefundBody();
            }else {
                this.errorMsg = "系统繁忙";
            }
        }else if (transferOrder.getRefundStatus() == 1){
            this.prompt = "提现成功";
            this.errorMsg = "";
        }else if (transferOrder.getRefundStatus() == 2 ||transferOrder.getRefundStatus() == 3){
            this.prompt = "提示：预计24小时内到账，实际结果以到账";
            this.errorMsg = "";
        }
        if (transferOrder.getRefundStatus() == 3){
            this.refundStatus = 2;
        }else {
            this.refundStatus = transferOrder.getRefundStatus();
        }

        this.refundTime = transferOrder.getRefundTime();
        this.paymentType = transferOrder.getPaymentType();
        this.createTime = transferOrder.getCreateTime();
    }
}
